# coding=<utf-8>
from django.db import models

# Create your models here.

class Kind(models.Model):
    kindid = models.AutoField(primary_key=True)
    kinkname = models.CharField(max_length=20) 
    
    class Meta():
        db_table = "Kind"

class Category(models.Model):
    cateid = models.AutoField(primary_key=True)
    kindid = models.ForeignKey(Kind)
    catename = models.CharField(max_length=30)
    resmount = models.IntegerField()
    
    class Meta():
        db_table = "Category"

class Tag(models.Model):
    tagid = models.AutoField(primary_key=True)
    tagname = models.CharField(max_length=30)
    
    class Meta():
        db_table = "Tag"

class Genres(models.Model):
    genresid = models.AutoField(primary_key=True)
    genresname = models.CharField(max_length=30)
    
    class Meta():
        db_table = "Genres"
        
class PeopleType(models.Model):
    typeid = models.AutoField(primary_key=True)
    typename = models.CharField(max_length=20)
    
    class Meta():
        db_table = "PeopleType"
        
    
class Actor(models.Model):
    actorid = models.AutoField(primary_key=True)
    typeid = models.ForeignKey(PeopleType)
    firstname_en = models.CharField(max_length=30)
    modelname_en = models.CharField(max_length=30)
    lastname_en = models.CharField(max_length=30)
    firstname_cn = models.CharField(max_length=30)
    middlename_cn = models.CharField(max_length=30)
    lastname_cn = models.CharField(max_length=30)
    contry = models.CharField(max_length=30)
    borndate = models.DateField()
    sex = models.BooleanField()                             # True-man; flase-woman
    descript = models.TextField()
    
    class Meta():
        db_table = "Actor"
        
    
class Video(models.Model):
    videoid = models.AutoField(primary_key=True)
    kindid = models.ForeignKey(Kind)
    resname = models.CharField(max_length=100)              #resource title
    title = models.CharField(max_length=200)                #video name
    downloadurl = models.CharField(max_length=500)          #download url
    posterurl = models.CharField(max_length=200)            #pseter url
    screenshoturls = models.CharField(max_length=1000)      #screen shot url
    trailerurls = models.CharField(max_length=1000)         #trailer url
    filesize = models.FloatField()                          #file size
    addedtime = models.DateTimeField()                      #added datetime
    imdb = models.CharField(max_length=100)                 #imdb url
    imdbscore = models.FloatField()                         #imdb score
    runtime = models.IntegerField()                         #video run time
    year = models.IntegerField()                            #year
    plot = models.TextField()                               #plot
    hits = models.IntegerField()                            #scans 
    downloadtimes = models.IntegerField()                   #downloads
    seeders = models.IntegerField()                         #seeder
    leechers = models.IntegerField()                        #leecher
    tags = models.CharField(max_length=100)                 #tags
    
    class Meta():
        db_table = "Video"
    
class Alias(models.Model):
    aliasid = models.AutoField(primary_key=True)
    aliasname = models.CharField(max_length=200)
    
    class Meta():
        db_table = "Alias"

class Video_Category(models.Model):
    vc_id = models.AutoField(primary_key=True)
    videoid = models.ForeignKey(Video)
    cateid = models.ForeignKey(Category)
    
    class Meta():
        db_table = "Video_Category"

class Video_Alias(models.Model):
    va_id = models.AutoField(primary_key=True)
    videoid = models.ForeignKey(Video)    
    aliasid = models.ForeignKey(Alias)
    
    class Meta():
        db_table = "Video_Alias"
    
class Video_Actor(models.Model):
    va_id = models.AutoField(primary_key=True)
    videoid = models.ForeignKey(Video)
    actorid = models.ForeignKey(Actor)
    
    class Meta():
        db_table = "Video_Actor"
        
    
class Video_Genres(models.Model):
    vg_id = models.AutoField(primary_key=True)
    videoid = models.ForeignKey(Video)
    genresid = models.ForeignKey(Genres)
    
    class Meta():
        db_table = "Video_Genres"
        
    
class Video_Tag(models.Model):
    vt_id = models.AutoField(primary_key=True)
    videoid = models.ForeignKey(Video)
    tagid = models.ForeignKey(Tag)
    
    class Meta():
        db_table = "Video_Tag"